package com.xczz.controller;

import com.xczz.common.base.BaseController;
import com.xczz.common.result.RestResult;
import com.xczz.common.result.TableDataInfo;
import com.xczz.model.SysUser;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/demo")
public class DemoController extends BaseController {
    @PostMapping
    public RestResult add(){
        boolean flag=true;
        return toAjax(flag?1:0);
    }

    @PutMapping
    public RestResult edit(){
        boolean flag=true;
        return toAjax(flag?1:0);
    }

    @DeleteMapping
    public RestResult remove(){
        boolean flag=true;
        return toAjax(flag?1:0);
    }
    @GetMapping(value = {"/","/{userId}"})
    public RestResult getInfo(@PathVariable(value ="userId",required = false) Long userId){
        RestResult ajax=RestResult.success();
        ajax.put("user",new SysUser());
        return ajax;
    }

    @GetMapping("/list")
    public TableDataInfo list(){
        return TableDataInfo.success(new ArrayList<>(),100);
    }

//    public static void main(String[] args) {
//        //连接本地的 Redis 服务
//        RedisProperties.Jedis jedis = new RedisProperties.Jedis("localhost");
//        System.out.println("连接成功");
//        //存储数量到表中
//        jedis.lpush("site-list","Runook");
//        jedis.lpush("site-list","Google");
//        jedis.lpush("site-list","Ladba2");
//        //获取存储的数量并输出
//        List<String> list = jedis.lrange("site-list", 0,2);
//       for(int i=0; i<list.size(); i++){
//            System.out.println("列表项为: "+list.get(i));
//        }
//        }
}
